<template>
  <el-form
    :inline="true"
    :model="formInline"
    style="margin-top: 40px; margin-left: 10px"
    class="demo-form-inline"
  >
    <el-form-item label="Year:">
      <el-input v-model="formInline.year" placeholder="input year" clearable />
    </el-form-item>
    <el-form-item label="Season:">
      <el-select
        v-model="formInline.season"
        placeholder="select season"
        clearable
      >
        <el-option label="spring" value="spring" />
        <el-option label="summer" value="summer" />
        <el-option label="autumn" value="autumn" />
        <el-option label="winter" value="winter" />
      </el-select>
    </el-form-item>
    <el-form-item label="Date: ">
      <el-date-picker
        v-model="formInline.date"
        type="date"
        placeholder="Pick a date"
        clearable
      />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">Query</el-button>
    </el-form-item>
  </el-form>
  <el-table :data="tableData">
    <el-table-column
      v-for="(column, index) in columns"
      :prop="column.prop"
      :label="column.prop"
      :key="index"
      width="auto"
    >
    </el-table-column>
  </el-table>
</template>

<script setup lang="ts" name="Chemical">
import { reactive } from "vue";

const formInline = reactive({
  year: "",
  season: "",
  date: "",
});

const onSubmit = () => {
  console.log("submit!");
};

let tableData = [
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
  {
    name: "2004",
    classiFication: "1.15",
    serialNumber: "summer",
    price: "unKnow",
    storagePlace: "demo",
    practicalUsedYears: "demo",
    dateManufacture: 0,
  },
];

const columns = Object.keys(tableData[0]).map((key) => ({
  prop: key,
  label: key.charAt(0).toUpperCase() + key.slice(1),
  width: 100,
}));
</script>

<style scoped>
.demo-form-inline .el-input {
  --el-input-width: 150px;
}
.demo-form-inline .el-select {
  --el-select-width: 150px;
}
.demo-form-inline .el-date-picker {
  --el-select-width: 150px;
}
</style>
